import * as jwt from 'jsonwebtoken'


export class JWTUtil {

    private static readonly privateKey: string = "bmVzdGpzIGFuZ3VsYXIgbmI="

    static generateToken(payload: any, expTimeS: number):string {
        payload.exp = Math.floor(Date.now() / 1000) + expTimeS;
        return jwt.sign(payload, JWTUtil.privateKey);
    }

    static verifyToken(token:string) {
        return jwt.verify(token, JWTUtil.privateKey);
    }
}